/*
package com.wk.config;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wk.dao.CmfzAdminDao;
import com.wk.entity.CmfzAdmin;
import org.apache.shiro.authc.*;
import org.apache.shiro.realm.AuthenticatingRealm;
import org.apache.shiro.util.ByteSource;
import org.springframework.beans.factory.annotation.Autowired;

public class MyAuthenRealm extends AuthenticatingRealm {
    @Autowired
    private CmfzAdminDao cmfzAdminDao;

    @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
//        1.获取用户输入的账号
        UsernamePasswordToken passwordToken = (UsernamePasswordToken) token;
        String username = passwordToken.getUsername();
//        2.查询数据库
        CmfzAdmin admin = cmfzAdminDao.selectOne(
                new QueryWrapper<CmfzAdmin>()
                        .eq("username", username)
        );
//        3.如果结果不为null 封装info返回
        if (admin != null){
            //将字符串的盐值转换为ByteSource类型
            ByteSource bytes = ByteSource.Util.bytes(admin.getSalt());

//            参数1 账号 参数2 密码 参数3 颜值 参数4 当前对象的名字
            return new SimpleAuthenticationInfo(admin.getUsername(),admin.getPassword(),bytes,this.getName());
        }
        return null;
    }
}
*/
